package cn.sytton.taffe.framework.response;

import com.fasterxml.jackson.annotation.JsonInclude;

/**
 * api返回值类
 *
 * @author skyrock
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ResponseResult {

    /**
     * 成功表示
     */
    private boolean success;

    /**
     * 返回数据，无数据时不返回此节点
     */
    private Object data;

    /**
     * 反馈信息，无错误时不返回此结果
     */
    private String message;

    private ResponseResult(boolean success, Object data, String message) {
        this.success = success;
        if (message != null) {
            this.message = message;
        }
        if (data != null) {
            this.data = data;
        }
    }
    public static ResponseResult success() {
        return new ResponseResult(true, null, null);
    }
    public static ResponseResult success(Object data) {
        return new ResponseResult(true, data, null);
    }
    public static ResponseResult fail() {
        return new ResponseResult(false, null, null);
    }
    public static ResponseResult fail(String message) {
        return new ResponseResult(false, null, message);
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

}
